<div id="primary" class="widget-area" role="complementary">
	<ul class="xoxo">
		<li><h2>Book Catalogue</h2></li>
		<li>-----------------------------------------------</li>
                <li>Search for a book by Title:</li>
                <li><br/></li>
		<li id="search" class="widget-container widget_search">
                    <form action="search.jsp" method=post>
                        <div>
                            <label class="screen-reader-text" for="s">Search for book:</label>
                            <input type="text" name="bookTitle" value="" size=20  maxlength=50>
                            <input type="submit" value="Search">
                        </div>
                    </form>
                </li>
                <li><h2>WishList</h2></li>
		<li>-----------------------------------------------</li>
                <%
                    if(session.getAttribute("list") != null){
                        out.println("<li>Books on your Wishlist:</li>");

                        String listContentsString = (String) session.getAttribute("list");
                        String[] listContents = listContentsString.split(",");

                        bookDatabase_pkg.bookDatabaseDriver driverList = new bookDatabase_pkg.bookDatabaseDriver();
                        String categoryList = "action";
                        int resultList = driverList.databaseConnect(categoryList);
                        if(resultList == 0){
                            //out.println("Database: " + category1 + " connected<br />");

                            for(int i=0; i<listContents.length; i++){
                                String[] bookList = driverList.getBook(listContents[i]);
                                if(bookList[0] != null){
                                    out.println("<li><table width='75%'><tr><td>");

                                    out.println("<form name='itemList" + bookList[0] + "' role='viewBook' method='get' id='searchform' action='book.jsp'>");
                                    out.println("<input type='hidden' value=" + categoryList + " name='category' id='category' />");
                                    out.println("<input type='hidden' value=" + bookList[0] + " name='ISBN' id='ISBN' />");
                                    out.println("<a href='' onclick='document.itemList" + bookList[0] + ".submit(); return false;'>" + bookList[1] + "</a>");
                                    out.println("</form>");

                                    out.println("</td><td> ");

                                    out.println("<form name='rmList" + bookList[0] + "' role='removeFromCart' method='get' id='searchform' action='removeFromList.jsp'>");
                                    out.println("<input type='hidden' value=" + bookList[0] + " name='ISBN' id='ISBN' />");
                                    out.println("(<a href='' onclick='document.rmList" + bookList[0] + ".submit(); return false;'>remove</a>)");
                                    out.println("</form>");

                                    out.println(" </td></tr></table></li>");
                                }
                            }
                        }
                        driverList = new bookDatabase_pkg.bookDatabaseDriver();
                        categoryList = "drama";
                        resultList = driverList.databaseConnect(categoryList);
                        if(resultList == 0){
                            //out.println("Database: " + category1 + " connected<br />");

                            for(int i=0; i<listContents.length; i++){
                                String[] bookList = driverList.getBook(listContents[i]);
                                if(bookList[0] != null){
                                    out.println("<li><table width='75%'><tr><td>");

                                    out.println("<form name='itemList" + bookList[0] + "' role='viewBook' method='get' id='searchform' action='book.jsp'>");
                                    out.println("<input type='hidden' value=" + categoryList + " name='category' id='category' />");
                                    out.println("<input type='hidden' value=" + bookList[0] + " name='ISBN' id='ISBN' />");
                                    out.println("<a href='' onclick='document.itemList" + bookList[0] + ".submit(); return false;'>" + bookList[1] + "</a>");
                                    out.println("</form>");

                                    out.println("</td><td> ");

                                    out.println("<form name='rmList" + bookList[0] + "' role='removeFromCart' method='get' id='searchform' action='removeFromList.jsp'>");
                                    out.println("<input type='hidden' value=" + bookList[0] + " name='ISBN' id='ISBN' />");
                                    out.println("(<a href='' onclick='document.rmList" + bookList[0] + ".submit(); return false;'>remove</a>)");
                                    out.println("</form>");

                                    out.println(" </td></tr></table></li>");
                                }
                            }
                        }
                        driverList = new bookDatabase_pkg.bookDatabaseDriver();
                        categoryList = "comedy";
                        resultList = driverList.databaseConnect(categoryList);
                        if(resultList == 0){
                            //out.println("Database: " + category1 + " connected<br />");

                            for(int i=0; i<listContents.length; i++){
                                String[] bookList = driverList.getBook(listContents[i]);
                                if(bookList[0] != null){
                                    out.println("<li><table width='75%'><tr><td>");

                                    out.println("<form name='itemList" + bookList[0] + "' role='viewBook' method='get' id='searchform' action='book.jsp'>");
                                    out.println("<input type='hidden' value=" + categoryList + " name='category' id='category' />");
                                    out.println("<input type='hidden' value=" + bookList[0] + " name='ISBN' id='ISBN' />");
                                    out.println("<a href='' onclick='document.itemList" + bookList[0] + ".submit(); return false;'>" + bookList[1] + "</a>");
                                    out.println("</form>");

                                    out.println("</td><td> ");

                                    out.println("<form name='rmList" + bookList[0] + "' role='removeFromCart' method='get' id='searchform' action='removeFromList.jsp'>");
                                    out.println("<input type='hidden' value=" + bookList[0] + " name='ISBN' id='ISBN' />");
                                    out.println("(<a href='' onclick='document.rmList" + bookList[0] + ".submit(); return false;'>remove</a>)");
                                    out.println("</form>");

                                    out.println(" </td></tr></table></li>");
                                }
                            }
                        }
                        %><li><br/></li>
                        <a HREF="wishlist.jsp"><input type="submit" value="Want to make List Public?"></a><%
                    }
                    else{
                        out.println("<li>Your Wishlist is blank!</li>");
                    }
                %>
                <li><br/></li>
                <li><h2>Shopping Cart</h2></li>
		<li>-----------------------------------------------</li>
                <%
                    if(session.getAttribute("cart") != null){
                        %> <li>Books in your cart:</li> <%

                        String cartContentsString = (String) session.getAttribute("cart");
                        String[] cartContents = cartContentsString.split(",");

                        bookDatabase_pkg.bookDatabaseDriver driverCart = new bookDatabase_pkg.bookDatabaseDriver();
                        String categoryCart = "action";
                        int resultCart = driverCart.databaseConnect(categoryCart);
                        if(resultCart == 0){
                            //out.println("Database: " + category1 + " connected<br />");

                            for(int i=0; i<cartContents.length; i++){
                                String[] bookCart = driverCart.getBook(cartContents[i]);
                                if(bookCart[0] != null){
                                    out.println("<li><table width='75%'><tr><td>");

                                    out.println("<form name='itemCart" + bookCart[0] + "' role='viewBook' method='get' id='searchform' action='book.jsp'>");
                                    out.println("<input type='hidden' value=" + categoryCart + " name='category' id='category' />");
                                    out.println("<input type='hidden' value=" + bookCart[0] + " name='ISBN' id='ISBN' />");
                                    out.println("<a href='' onclick='document.itemCart" + bookCart[0] + ".submit(); return false;'>" + bookCart[1] + "</a>");
                                    out.println("</form>");

                                    out.println("</td><td> ");

                                    out.println("<form name='rmCart" + bookCart[0] + "' role='removeFromCart' method='get' id='searchform' action='removeFromCart.jsp'>");
                                    out.println("<input type='hidden' value=" + bookCart[0] + " name='ISBN' id='ISBN' />");
                                    out.println("(<a href='' onclick='document.rmCart" + bookCart[0] + ".submit(); return false;'>remove</a>)");
                                    out.println("</form>");

                                    out.println(" </td></tr></table></li>");
                                }
                            }
                        }
                        driverCart = new bookDatabase_pkg.bookDatabaseDriver();
                        categoryCart = "drama";
                        resultCart = driverCart.databaseConnect(categoryCart);
                        if(resultCart == 0){
                            //out.println("Database: " + category1 + " connected<br />");

                            for(int i=0; i<cartContents.length; i++){
                                String[] bookCart = driverCart.getBook(cartContents[i]);
                                if(bookCart[0] != null){
                                    out.println("<li><table width='75%'><tr><td>");

                                    out.println("<form name='itemCart" + bookCart[0] + "' role='viewBook' method='get' id='searchform' action='book.jsp'>");
                                    out.println("<input type='hidden' value=" + categoryCart + " name='category' id='category' />");
                                    out.println("<input type='hidden' value=" + bookCart[0] + " name='ISBN' id='ISBN' />");
                                    out.println("<a href='' onclick='document.itemCart" + bookCart[0] + ".submit(); return false;'>" + bookCart[1] + "</a>");
                                    out.println("</form>");

                                    out.println("</td><td> ");

                                    out.println("<form name='rmCart" + bookCart[0] + "' role='removeFromCart' method='get' id='searchform' action='removeFromCart.jsp'>");
                                    out.println("<input type='hidden' value=" + bookCart[0] + " name='ISBN' id='ISBN' />");
                                    out.println("(<a href='' onclick='document.rmCart" + bookCart[0] + ".submit(); return false;'>remove</a>)");
                                    out.println("</form>");

                                    out.println(" </td></tr></table></li>");
                                }
                            }
                        }
                        driverCart = new bookDatabase_pkg.bookDatabaseDriver();
                        categoryCart = "comedy";
                        resultCart = driverCart.databaseConnect(categoryCart);
                        if(resultCart == 0){
                            //out.println("Database: " + category1 + " connected<br />");

                            for(int i=0; i<cartContents.length; i++){
                                String[] bookCart = driverCart.getBook(cartContents[i]);
                                if(bookCart[0] != null){
                                    out.println("<li><table width='75%'><tr><td>");

                                    out.println("<form name='itemCart" + bookCart[0] + "' role='viewBook' method='get' id='searchform' action='book.jsp'>");
                                    out.println("<input type='hidden' value=" + categoryCart + " name='category' id='category' />");
                                    out.println("<input type='hidden' value=" + bookCart[0] + " name='ISBN' id='ISBN' />");
                                    out.println("<a href='' onclick='document.itemCart" + bookCart[0] + ".submit(); return false;'>" + bookCart[1] + "</a>");
                                    out.println("</form>");

                                    out.println("</td><td> ");

                                    out.println("<form name='rmCart" + bookCart[0] + "' role='removeFromCart' method='get' id='searchform' action='removeFromCart.jsp'>");
                                    out.println("<input type='hidden' value=" + bookCart[0] + " name='ISBN' id='ISBN' />");
                                    out.println("(<a href='' onclick='document.rmCart" + bookCart[0] + ".submit(); return false;'>remove</a>)");
                                    out.println("</form>");

                                    out.println(" </td></tr></table></li>");
                                }
                            }
                        }
                        %><li><br/></li>
                        <a HREF="checkout.jsp"><input type="submit" value="Go to Checkout"></a><%
                    }
                    else{
                        out.println("<li>There are no books in your cart!</li>");
                    }
                %>
	</ul>
</div><!-- #primary .widget-area -->